package com.example.demo;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import  java.lang.reflect.Proxy;
public class ProxyDemo {
    public static void main(String[] args) {
        BuilderDemo.Test test=(Test)Proxy.newProxyInstance(ProxyDemo.class.getClassLoader(),
                new Class[]{
                        Test.class
                }, new InvocationHandler() {
                    @Override
                    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
                        System.out.println(method.getName()+"被调用了");
                        return method.invoke(target,args);
                    }
                });
        System.out.println(test.hai(name="nihao"));
    }
    public static class  TestImplProxy extends TestImpl{

    }
}
